package com.woniuxy01;

import java.math.BigDecimal;
import java.math.BigInteger;

/**
 * @author 作者
 * @create 2025-09-10 14:45
 */
public class Test03 {
    public static void main(String[] args) {
        BigDecimal b1=new BigDecimal("10000000000000000000000000000000");
        BigDecimal b2=new BigDecimal("6");
        System.out.println(b1.add(b2));
        System.out.println(b1.subtract(b2));
        System.out.println(b1.multiply(b2));
        //BigDecimal divisor,
        // int scale,   保留的小数位数
        // int roundingMode:舍入模式BigDecimal.ROUND_HALF_UP四舍五入
        System.out.println(b1.divide(b2,9,BigDecimal.ROUND_HALF_UP));
        System.out.println(b1.divide(b2,9,BigDecimal.ROUND_DOWN));
        System.out.println(b1.divide(b2,9,BigDecimal.ROUND_UP));
    }

    private static void test02() {
        System.out.println(Long.MAX_VALUE);
        long a=9999999999L;
        BigInteger b1=new BigInteger("99999999999999999999999999999999999");
        BigInteger b2=new BigInteger("9999999999999999999999");
        System.out.println(b1.add(b2));
        System.out.println(b1.subtract(b2));
        System.out.println(b1.multiply(b2));
        System.out.println(b1.divide(b2));
        BigInteger[] result = b1.divideAndRemainder(b2);
        System.out.println(result[0]);
        System.out.println(result[1]);
    }

    private static void test01() {
        int i=Integer.MAX_VALUE;
        System.out.println(i);
        i++;
        System.out.println(i);
        System.out.println(Integer.MIN_VALUE);
    }
}
